package chenji.dailykit.ItemEditor;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
/**
 * @author ChenJi Copyright (c) 2016 ChenJi. All rights reserved.
 */
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;

import chenji.dailykit.Main;

public final class ItemEditorListener implements Listener {
	@EventHandler
	public void PlayerChatEvent(final AsyncPlayerChatEvent e) {
		if (e.isCancelled()) {
			return;
		}
		e.setCancelled(Main.getItemEditorManager().getItemEditorEventManager().setPlayerChat(e.getPlayer(), e.getMessage()));
	}

	@EventHandler
	public void InventoryClickEvent(final InventoryClickEvent e) {
		Player p = (Player) e.getWhoClicked();
		if (e.isCancelled()) {
			return;
		}
		if (Main.getItemEditorManager().containItemEditor(p)==false) {
			return;
		}
		e.setCancelled(
				Main.getItemEditorManager().clickInventory(e.getInventory(), p, e.getSlot()));
	}

}
